﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Channels;
using System.IO;
using System.Xml;

namespace HomeFramework.Core
{
    [Obsolete("Use MessageMtomByteWriter")]
    public class MessageByteWriter
    {
        public static byte[] WriteMessage(Message arg)
        {
            using (var m = new MemoryStream())
            {
                using (var x = XmlWriter.Create(m))
                {
                    arg.WriteMessage(x);
                }
                return m.ToArray();
            }
        }

        public static Message ReadMessage(byte[] arg)
        {
            var m = new MemoryStream(arg);
            var x = XmlReader.Create(m);
            return Message.CreateMessage(x, int.MaxValue, MessageVersion.Default);
        }
    }
}
